<?php

require("header.php");
include ("engine/sql.inc.php");
if (isset($_GET['name'])){
	$stud_name = $_GET['name'];
	$stud_name = clean($stud_name);
} 
if (isset($_GET['no'])){
	$stud_no = $_GET['no'];
	$stud_no = clean($stud_no);
}
if (isset($_GET['ic'])){
	$stud_ic = $_GET['ic'];
	$stud_ic=clean($stud_ic);
}
if (isset($_GET['course'])){
	$stud_course=$_GET['course'];
	$stud_course=clean($stud_course);
}
if (isset($_GET['department'])){
	$stud_department=$_GET['department'];
	$stud_department=clean($stud_department);
}
if (isset($_GET['sem'])){
	$stud_sem=$_GET['sem'];
	$stud_sem=clean($stud_sem);
}
?>

<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
.style2 {
	font-size: 18px;
	font-weight: bold;
	color: #000000;
}
.style5 {color: #CCCCCC}
body {
	background-color: #FFFFFF;
}
.style7 {color: #000000}
-->
</style></head>

<body>
<?php
	$sql_fetch_course="SELECT dep_name,dep_code FROM deparment ORDER BY dep_name ASC";
	$result = mysql_query($sql_fetch_course);
	$sql_fetch_sem="SELECT sem_num FROM semester ORDER BY sem_num ASC";
	$result2=mysql_query($sql_fetch_sem);
	$sql_fetch_course="SELECT course_name,course_code FROM course ORDER BY course_name ASC";
	$result3=mysql_query($sql_fetch_course);
?>
<br />
<div align="center">
  <form name="stud_reg" method="POST" action="engine/stud_reg.inc.php">
    <table width="780" border="1" align="center" bordercolor="#CCCCCC">
    <tr>
      <td><br />
        <center><img src="images/user.png"/>
          </center>
        <p align="center" class="style2 style5">STUDENT REGISTRATION FORM</p>
        <table width="621" border="0" align="center">
        <tr>
          <td width="234"><span class="style7">Name</span></td>
          <td width="8"><span class="style7">:</span></td>
          <td width="365"><input name="stud_name" type="text" id="stud_name" size="60" maxlength="255" 
		  <?php if (isset($stud_name)) { echo "value=\"".$stud_name."\""; }?>/></td>
        </tr>
        
        <tr>
          <td valign="top"><span class="style7">Student Number </span></td>
          <td valign="top" bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <input type="text" onKeyUp="js_validate(this.value)" size="30" name="stud_no"
		  <?php if (isset($stud_no)) { echo "value=\"".$stud_no."\""; }?>/>
            * This will be your login id </span><br>
		    <span style="font-weight:normal;" id="validation"></span></td>
        </tr>
        <tr>
          <td><span class="style7">Password</span></td>
          <td bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <input name="stud_password" type="password" id="stud_password" size="20" />
            * Please use secure password </span></td>
        </tr>
        <tr>
          <td><span class="style7">Identification Card Number </span></td>
          <td bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <input name="stud_ic" type="text" id="stud_ic" size="20" maxlength="12" 
		  <?php if (isset($stud_ic)) { echo "value=\"".$stud_ic."\""; }?>/>
             * Example 841221055067 </span></td>
        </tr>
        
        <tr>
          <td><span class="style7">Student Course </span></td>
          <td bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <select name="stud_course" id="stud_course">
			  <option value=""></option>
                <?php if (isset($stud_course)){
					$sql_fetch_course1="SELECT course_name,course_code FROM course WHERE course_code='$stud_course'";
					$get1=mysql_query($sql_fetch_course1);
					$get11=mysql_fetch_assoc($get1); ?>
					<option value="<?php echo $get11['course_code']; ?>" selected><?php echo $get11['course_name']; ?></option>
				<?php
				} else {
				while ($course = mysql_fetch_assoc($result3)) { ?>
              <option value="<?php echo $course['course_code']; ?>"><?php echo $course['course_name']; ?></option>
                  <?php }
				  } ?>
              </select>
          </span> </td>
        </tr>
        
        <tr>
          <td><span class="style7">Student Semester </span></td>
          <td bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <select name="stud_sem">
			  <option value=""></option>
			  <?php if (isset($stud_sem)){
					$sql_fetch_sem1="SELECT sem_num FROM semester WHERE sem_num='$stud_sem'";
					$get2=mysql_query($sql_fetch_sem1);
					$get22=mysql_fetch_assoc($get2); ?>
					<option value="<?php echo $get22['sem_num']; ?>" selected><?php echo $get22['sem_num']; ?></option>
				<?php
				} else {
                 while ($sem = mysql_fetch_assoc($result2)) { ?>
              <option value="<?php echo $sem['sem_num']; ?>"><?php echo $sem['sem_num']; ?></option>
                  <?php } }?>
              </select>
          </span> </td>
        </tr>
        
        <tr>
          <td><span class="style7">Student Class</span> </td>
          <td bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <select name="stud_class" id="stud_class">
              <option></option>
              <option value="A">A</option>
              <option value="B">B</option>
              <option value="C">C</option>
            </select>
          </span> </td>
        </tr>
        <tr>
          <td><span class="style7">Student Department </span></td>
          <td bordercolor="0"><span class="style7">:</span></td>
          <td><span class="style7">
            <select name="stud_department" id="stud_department">
			  <option value=""></option>
			  <?php if (isset($stud_department)){
					$sql_fetch_dep1="SELECT dep_name,dep_code FROM deparment WHERE dep_code='$stud_department'";
					$get3=mysql_query($sql_fetch_dep1);
					$get33=mysql_fetch_assoc($get3); ?>
					<option value="<?php echo $get33['dep_code']; ?>" selected><?php echo $get33['dep_name']; ?></option>
				<?php
				} else {
                while ($row = mysql_fetch_assoc($result)) { ?>
              <option value="<?php echo $row['dep_code']; ?>"><?php echo $row['dep_name']; ?></option>
                <?php } }?>
              </select>
          </span> </td>
        </tr>
      </table>
        <p>&nbsp;</p>
        <p align="center">
        <input type="image" src="images/reg_button.png" alt="Submit Button"/>&nbsp;&nbsp;</p></td>
    </tr>
  </table>
  </form>
</div><br />

<?php require ("footer.php"); ?>
